7. Browsing Source Code



This chapter describes CodeWarrior's class browser, a tool you use to examine your project source code from various perspectives.

The CodeWarrior browser creates a database of all the symbols in your code, and provides you with a user interface to access the data quickly and easily, regardless of language.

Historically, programmers have used browsers primarily with object-oriented code, but the CodeWarrior IDE browser works with both procedural and object-oriented code. It works with most compilers, including C, C++, Pascal, and Java.

To help you understand the browser, we are going to look at it from three perspectives: high-level architecture, user interface, and functionality.

The topics in this chapter include:


Activating the Browser

To learn more about how to activate the browser, refer to:

When the browser is activated, the compiler generates the browser database information.

For more information on browser settings and options, see "Setting Browser Options" on page 241.

To learn how to use contextual menus in the browser, see "Browser Contextual Menu" on page 211.


Understanding the Browser Strategy

When you activate the browser, the CodeWarrior IDE compilers generate a database of information about your code. This database includes data not only about your code, but also about the relationships between various parts of your code, such as inheritance hierarchies.

The browser is a user interface that allows you to sort and sift through this information in ways that suit your needs.

Like any good database access program, the browser does not dictate how you should look at your information. It gives you a variety of tools to suit your working style.

There are three principal ways of looking at the information available to you in the browser:

These sections take a brief look at each option. "Guided Tour of the Browser" on page 210 discusses the user interface in detail.

The browser also implements instant access to information. By right-clicking (Windows) or clicking and holding the mouse (Mac OS, Solaris, and Linux) on any symbol for which there is information in the database, you get instant access to related source code. "Browser Contextual Menu" on page 211 discusses this feature.

In addition, the browser lets you decide the scope of the view. You can look at data in all your classes, or you may wish to focus on one class.

Within the browser and hierarchy views, you can look at multiple classes or single classes. Table 7.1 summarizes the various major choices you have when using the browser.

Table 7.1 Browser viewing options

Viewing Style
Wide Focus
Narrow Focus
comprehensive
contents
not applicable
inheritance-based
multi-class
hierarchy
single-class
hierarchy

The browser-related menu commands in the Window Menu-Browser Contents, Class Hierarchy Window, and New Class Browser-display wide-focus views. Once you have the wide view, you can focus on a particular class.

No matter what viewing style or focus you happen to be in at any given moment, the browser has simple and intuitive mechanisms for switching to another kind of view.


Contents View

The Contents view lets you see all of your data sorted by category into alphabetical lists. Figure 7.1 shows a Contents view.

You select the particular category you want to examine. You can focus on classes, constants, enumerations, routines, global variables, macros, routine templates, and type definitions.

See "Contents Window" on page 213 for details on the Contents window interface.

Figure 7.1 A Contents view



Browser View

The Browser view is like a traditional class browser. You use this view to look at your data from a class-oriented perspective. Figure 7.2 shows what a Browser view looks like.

In the Browser view, you have a list of classes. For the selected class in that list, you see all of its member routines and its data members. When you select an item, the source code related to that item is displayed in the Source pane.

See "Browser Window" on page 214 for details on the user interface elements in the Browser view.

Figure 7.2 A Browser view



NOTE

The Browser view has a toolbar. To learn how to use and customize the toolbar, see "Customizing the IDE" on page 289. The Browser view also has a tab control when browsing rapid application development (RAD) projects. For more information about the tab control, refer to "RAD Browsing" on page 559.

Hierarchy View

The Hierarchy view is a graphical view of your class hierarchy. You use this view to understand or follow class relationships. Figure 7.3 illustrates a multi-class hierarchy view for some classes.

Figure 7.3 A Hierarchy view


The Hierarchy view gives you a real feel for the way your classes are connected with each other. You can expand and collapse a hierarchy at will.

See "Multi-Class Hierarchy Window" on page 221 and "Single-Class Hierarchy Window" on page 223 for details on the Hierarchy view interface.


Guided Tour of the Browser

At first glance, the browser interface is quite complicated. There are multiple windows filled with controls and information. However, there are really only three kinds of views: Contents, Browser, and Hierarchy.

In addition, the browser contextual menu is a fundamental and vital feature of the browser interface. The contextual menu is available for any symbol for which the browser database has data. The menu commands describe various actions that you can perform on the selected item.

For object-oriented code (member functions only), you have the opportunity to see the declaration or definition of any routine with that name. You can also open up a symbol browser that lists every implementation of the routine. Depending on the nature of the symbol (class name, routine name, enumeration, and so forth), the contextual menu lists different destinations appropriate for the item. This gives you instant access to the source code related to any symbol.

This section examines each window used by the browser and the browser controls. The sections are:


Browser Contextual Menu

When the browser is active, right-click (Windows) or click and hold (Mac OS, Solaris, and Linux) on any symbol for which there is data in the browser database. When you do, the IDE displays a contextual menu with a variety of items.

The commands displayed in the menu depend on the nature of the symbol you are investigating. Some commands let you open browser windows, while other commands direct you to a location in code.

You can also use the contextual menu to perform common debugging tasks. For example, you can choose commands to set and clear breakpoints in the active editor window.

In effect, every symbol in your code-routine name, class name, data member name, constant, enumeration, template, macro, type definition, and so forth-becomes a hypertext link to other locations in your source code.

For example, if you select class name and use the browser contextual menu, you can open the class declaration, a Browser Window, or a Single-Class Hierarchy Window. If you use the contextual menu for a routine name, you get different choices, as shown in Figure 7.4.

Figure 7.4 A browser contextual menu for a routine


You can even insert a routine template at the location if you wish. See "Browser Display" on page 268 for more information.

Other menus for other kinds of symbols have similar commands.


TIP

To find and enter a browser item for a piece of text you have selected or just entered, invoke the browser contextual menu for that text. The menu offers a list of matching items. Choose one of these items to enter it for you. See "Completing Symbols" on page 243 for other ways to type browser items.

TIP

The contextual menu features work not only in browser windows, but also in the CodeWarrior source code editor! This is a great reason for always having the browser enabled, even if you do not use the browser windows.

Of particular note in the contextual menu for routine names is the Find all implementations of command. When you choose this command for a routine that has multiple definitions, a Symbol Window opens in the browser.


Contents Window

The Contents window displays browser data sorted by category into alphabetical lists. Choose Browser Contents from the Window Menu to display the Contents window, shown in Figure 7.5.

Figure 7.5 A Contents window


The items in this window are:


Category pop-up menu

The Category pop-up menu select the type of information displayed in the Symbols pane. The currently selected item is highlighted (Windows) or checked (Mac OS, Solaris, and Linux).


Symbols pane

The Symbols pane displays every item in the browser database that is a member of the currently selected category. The items are listed alphabetically.


NOTE

Routines are listed alphabetically by routine name, but the class name is displayed first. As a result, it may seem that the routines are not listed alphabetically.

Browser Window

The Browser window (Figure 7.2 on page 209) gives you a class-based view of the information in the browser database. The window has several panes displaying lists of information.

You can open Browser window using several techniques:


TIP

The Browser window has a toolbar. To learn how to use and customize the toolbar, see "Customizing the IDE" on page 289. When browsing rapid application development (RAD) projects, the Browser window has a tab control. To learn how to use the tab control, refer to "RAD Browsing" on page 559.

The Classes pane, Member Functions pane, and Data Members pane are lists of their respective data. Clicking within a particular pane makes it the active pane. You can also use the Tab key to rotate through all the panes (except for the Source pane).


TIP

Using the Tab key can be mildly hazardous to your source code. If the Source pane is active and you press the Tab key, you enter a tab into your source code. Once you are in the Source pane, you cannot press the Tab key to get out of it.


Windows

Use the mouse to select a different pane.


Mac OS, Solaris, and Linux

Use the mouse or press Option-Tab to move to a different pane. A focus outline surrounds the active pane.

You can click an item in any list to select it, or navigate through the items in the active list by typing or using the arrow keys. You can also select items by typing their names. The selection changes to most closely match the characters you type.


Mac OS, Solaris, and Linux

Use the Control-Tab key combination to cycle through list items alphabetically.

The items in this window include:


Browser toolbar

The toolbar provides easy single-click access to many CodeWarrior commands. The buttons that are displayed in the Browser window's toolbar are listed in Table 7.2.

Table 7.2 Browser toolbar buttons

Button
Description
Go Back
Go Forward
Show Browser Contents window
Show Multi-Class Hierarchy window
Show Single-Class Hierarchy window


Browser Access Filters pop-up menu

The Browser Access Filters pop-up menu controls the display of member functions and data members in the Browser view. The pop-up menu's commands "filter" the display according to public, private, and protected access types. A mark is displayed next to each enabled filter. The available choices in the pop-up menu are described in Table 7.3.

The first three choices represent shortcuts to multiple filters. For example, instead of using the Browser Access Filters pop-up menu three times in succession to enable public, private, and protected filters, choose View as implementor to enable all three filters simultaneously.

After you enable a particular filter, the access icons change in the bottom-right corner of the Browser window. Darkened icons, as shown in Table 7.3, indicate enabled filters. Grayed-out icons represent disabled filters.

Table 7.3 Browser Access Filters pop-up menu commands

Command
Access Icon
Show items with
View as implementor
public, private, and
protected access
View as subclass
public and protected access
View as user
public access
Show public
public access
Show protected
protected access
Show private
private access


Pane zoom box

The pane zoom box enlarges and shrinks panes in the browser.

Click this box to enlarge a pane to fill the Browser window.

Click this box to shrink a pane to its original size.


Resize bar

A resize bar is located between each pair of panes, as illustrated in Figure 7.2 on page 209. To resize two panes, drag the resize bar located between them.


TIP

When a source file is displayed in the Source pane, pressing Control/Command-\Q opens the associated interface file. If the file in the Source pane is an interface file, you open the related source code file, and vice versa.

Classes pane

The Classes pane lists all the classes in the browser database.

You can view the list alphabetically or by class hierarchy. Toggle the view by clicking the List button at the top right of the pane, as shown in Figure 7.2 on page 209.

In the Hierarchy view, hierarchy expansion triangles are displayed next to class names that have subclasses, as shown in Figure 7.3 on page 210. Click the expansion triangle to show or hide subclasses.


TIP

In the Classes pane, Alt/Option click a hierarchical control to open all subclasses at all levels. This is a "deep" disclosure. Ctrl/Command click to open a single level of subclass in a class and all of its siblings at the same level. This is a "wide" disclosure. Ctrl/Command-Alt/Option-click to open both wide and deep.

When you select a class in the Classes pane, the Multi-Class Hierarchy Window selection changes too. The Hierarchy view scrolls to the newly selected class if necessary.


NOTE

The Classes pane does not display information about classes or structures that do not have any member functions, base classes, or subclasses. Thus, structures and classes that just have fields and data members are not displayed.

List button

The List button at the top right of the Classes pane controls the listing of classes. You can toggle between an alphabetical list or a hierarchical list.

Click this button to switch to an alphabetical list.

Click this button to switch to a hierarchical list.

Figure 7.6 The Browser window with the Classes pane hidden



Classes Pane button

The Classes Pane button at the bottom left of the Browser window controls the display of the Classes pane.

Click this button to hide the Classes pane (Figure 7.6).

Click this button to display the Classes pane (Figure 7.2).


Class Declaration button

After you click the Class Declaration button, the Source pane shows the declaration of the current class. This class is shown in the Status area of the Browser window.


Member Functions pane

The Member Functions pane lists all member functions defined in the selected class. Constructors and destructors are at the top of the list. After that, all other entries are listed in alphabetical order.

You can also display inherited member functions by enabling the Show Inherited checkbox in the toolbar. The Inherited access icon in the Browser window () darkens to indicate that inherited member functions are currently displayed.


TIP

If you select a member function in the Member Functions pane in the Browser Window, you can use the Enter/Return key to open an editor window and view the definition of the selected function.

Data Members pane

The Data Members pane lists all data members defined in the selected class. You can also display inherited data members by enabling the Show Inherited checkbox in the toolbar. The Inherited access icon in the Browser window () darkens to indicate that inherited data members are currently displayed.

The entries in the Data Members pane are listed in alphabetical order. If inherited members are displayed, data members are listed by superclass, but alphabetically within each class.


TIP

If you select a data member in the Data Members pane in the Browser Window, you can use the Enter/Return key to open an editor window and view the declaration of the selected data member.

Identifier icon

A routine or data member can have an identifier icon beside its name. The following table describes the icons.

Table 7.4 Browser identifier icons

Icon
Meaning
The member is
static
a static member
virtual
a virtual function that you can override, or an override of an inherited function
pure virtual or abstract
a member function that you must override in a subclass if you want to create instances of that subclass


Source pane

The Source pane displays the source code for the selected item. If the item is a class, the pane shows the class declaration. If the item is a routine, the pane shows the routine definition. If the selected item is a data member, the pane shows the data member declaration from the interface file.


NOTE

If you Alt/Option click an item in the Member Functions pane or the Data Members pane, that item is entered into the Source pane text at the current insertion point. This is an efficient way to enter routine calls or variable names into the Source pane.

The text in the Source pane is fully editable. The path to the file that contains the code on display is shown at the top of the Source pane.


Open File icon

The Open File icon is located at the top of the Source pane. Click this icon to open the file that contains the code displayed in the Source pane. The source code is displayed in a new editor window.


VCS pop-up menu

This pop-up menu lets you use revision control with the source file you are viewing. To learn more about how to use this feature, refer to the discussion in "Common VCS Operations" on page 593.


Status area

The status area displays various status messages and other information. For example, when you select a class from the Classes pane, the status area displays the base class(es) for the selected class.


Multi-Class Hierarchy Window

The Multi-Class Hierarchy window displays a complete graphical map of the classes in the browser database. Each class name is displayed in a box, and related classes are connected to each other by lines. Choose Class Hierarchy Window from the Window Menu to display the Multi-Class Hierarchy window. Figure 7.7 shows the Multi-Class Hierarchy window.

Figure 7.7 The Multi-Class Hierarchy window


Use the arrow keys to change the selected class "geographically." The up and down keys work on siblings. The left and right keys work on ancestors and descendants.

You can use the keyboard to change the selection. The current selection most closely matches the characters you type. Use the Tab key to change the selected class alphabetically.


TIP

If you select a class in the Classes pane in the Browser Window, the selection in the Multi-Class Hierarchy Window changes too.

If you double-click a class entry, or select the entry and press the Enter/Return key, you open a Browser Window for that class.

In addition to the entry for each class, the Multi-Class Hierarchy window has three items:


Line button

The Line button controls the display of the lines that connect related classes. You can toggle between diagonal lines and straight lines. The choice is entirely aesthetic.


Hierarchy expansion triangle

The hierarchy expansion triangle controls the display of subclasses.

If you click this triangle, the next level of subclasses is displayed or hidden from view. To be more precise, the expanded state restores to what it was the last time this class was open.


NOTE

Alt/Option click a disclosure triangle to open all subclasses at all levels. This is a "deep" disclosure. Ctrl/Command click to display subclasses for a class and all of its siblings. This is a "wide" disclosure. Ctrl-Alt-click (Windows) or Command-Option-click (Mac OS, Solaris, and Linux) to open both wide and deep. You can use Ctrl/Command-Alt/Option-click to expand or collapse an entire map if you click the expansion triangle for a base class that has no ancestors.

Ancestor Class pop-up menu

Click on the Ancestor Class triangle, shown in Figure 7.7, to display a pop-up menu. This menu lists immediate ancestors. When you choose an item from the pop-up menu, you jump to that class in the map. If the item is not currently visible, the computer beeps.

This control is displayed only for classes that have multiple base classes.


Single-Class Hierarchy Window

The Single-Class Hierarchy window displays a complete graphical map for a single class in the browser database. The map displays all immediate ancestors of the class, and all of its descendants. (The Multi-Class Hierarchy Window only shows one base class.)

Figure 7.8 shows the Single-Class Hierarchy window, displaying multiple base classes and subclasses. The underlined class name is the focus of the window.

Figure 7.8 The Single-Class Hierarchy window

You can open a single class hierarchy view using several techniques:

The Single-Class Hierarchy Window is identical to the Multi-Class Hierarchy Window, except that it displays a limited map. For information about how this window behaves, see "Multi-Class Hierarchy Window" on page 221.


Symbol Window

The Symbol window lists all implementations of any symbol that has multiple definitions. Most commonly, these symbols are multiple versions of overridden functions in object-oriented code. However, the Symbol window works for any symbol that has multiple definitions in the browser database.

After selecting an implementation in the Symbol window list, you see its definition in the Source pane. Figure 7.9 on page 225 shows the Symbol window.

You open a Symbol window by right-clicking (Windows) or clicking and holding (Mac OS, Solaris, and Linux) on a symbol name in any browser or editor window for which there is information in the browser database. When you do, a Browser Contextual Menu is displayed. If the item has multiple implementations, choose Find all implementations of. When you choose that item, the Symbol window displays.


TIP

In a Source pane or editor window, Alt/Option-double-click or Ctrl/Command-double-click a function or other symbol name to find all implementations and open the Symbol window without using the contextual menu.

Figure 7.9 The Symbol window


Most of the items in this window are identical to the Browser Window. For a discussion of the window in general, see "Browser Window" on page 214. That topic includes discussion of these items, also found in the Symbol window:

The Symbol window also has two unique items: the Symbols pane and the Orientation button.

The Symbols pane has the focus outline in Figure 7.9. This pane lists all versions of a symbol in the database. When you select an item in the Symbols pane, that item's definition is displayed in the Source pane.

The Orientation button toggles the position of the Symbols pane and the Source pane. The position toggles between Figure 7.9 and Figure 7.10.

Figure 7.10 The Symbol window in vertical orientation



Browser Menu

When a Contents View, Browser View, or Hierarchy View is visible, the Browser menu is displayed in CodeWarrior's menu bar. You use the commands in this menu to create new items. The IDE opens a wizard based on the command you select. The wizard presents various options to help you create a new class, member function, or data member.

The following list describes the commands in the Browser menu:


Browser Wizards

When creating a new class, member function, or data member, you select a Browser wizard. The wizard helps you complete the item-creation process. This section describes the following wizards:

For beginners

Each wizard assumes you have a basic understanding of the associated programming language. If the items in the wizard are unfamiliar to you, consult additional programming language references for more information.

The Browser wizards include the following navigation buttons:

Each wizard is divided into a series of steps. You progress through these steps in sequence, and each step builds on the information provided in previous steps. When you supply enough information in a particular step, click Next to continue.

You can modify the default settings in each step. To accept all current settings in the wizard, click Finish. The wizard displays a summary of all the current settings for the new project. Click Generate to accept the current settings and create the new RAD item, or click Cancel to return to the wizard and continue modifying settings.


New Class Wizard

The New Class wizard is divided into the following steps:

1. Describe the name and location for the new class.

2. Specify base classes and methods for the new class.

3. List #include files for the new class.

4. Assign the new class to the project's build targets.

To use the New Class wizard, follow these steps:

1. Describe the name and location for the new class.

This section of the wizard, shown in Figure 7.11, lets you specify the name, declaration, and location for the new class. Other options are available to further describe the class.

This section includes the following parts:


Class Name

Enter a name for the class in this field.


Declaration File

This pop-up menu lets you specify the type of declaration file:

Figure 7.11 New Class wizard - Name and Location


Depending on the option you choose, different fields become enabled below the Declaration File pop-up menu. The enabled fields for the New File option are shown in Figure 7.11, and the enabled fields for the Relative to class option are shown in Figure 7.12.

If you choose the New File option, type in the enabled field the path to which you want to save the file. Alternatively, click Set next to the field to save the file using a standard Save window.

If you choose the Relative to class option, the pop-up menu and the class field beside it become enabled, as shown in Figure 7.12. In the class field, type the name of the class you want to relate to the new class. Alternatively, click Set next to the class field, select a class in the window that opens, and then click Select. Next, use the pop-up menu to place the new class Before or After the class in the class field.

Figure 7.12 Choosing the Relative to class option



Namespace

In this field, type a namespace for the new class. Each name in the namespace should be unique.


Use separate file for member definitions

Enable this checkbox if you want to use a separate file to define the members of the new class. Type the path to the separate file in the field below the checkbox. Alternatively, click Existing to select the file using a standard dialog box. To create a new separate file, click New and save the new file to a location on your hard disk.

2. Specify base classes and methods for the new class.

This section of the wizard, shown in Figure 7.13, lets you define base class, methods, and additional information for the new class.

Figure 7.13 New Class wizard - Base Class and Methods


This section includes the following parts:


Base Classes

Enter in this field a list of base classes for the new class. Some example base classes are provided.


Generate Constructor and Destructor

Enable this checkbox to generate a constructor and destructor for the new class. After enabling this checkbox, the following options become available:


Namespaces required for base classes and constructor parameters (optional)

If you wish, you can enter in this field required namespaces for the base classes from the Base Classes field and the constructor parameters in the Generate Constructor and Destructor part of the wizard.

3. List #include files for the new class.

This section of the wizard, shown in Figure 7.14, lets you specify additional header #include files for the new class.

This section includes the following parts:


Include files that will automatically be added for base classes

This field shows you a list of #include files that will be automatically added to the base classes.


Additional header include files

Enter in this field a list of other #include files for the new class, in addition to those listed in the previous field. Separate each file in the list with a comma. Sample files are listed below the field.

Figure 7.14 New Class wizard - Include Files


4. Assign the new class to the project's build targets.

This section of the wizard, shown in Figure 7.15, lets you assign the new class to particular build targets within the active project.

This section includes the following parts:


Project

This field shows you the path to the project whose build targets are listed in the next field.


Add files to targets

To assign the class to a specific build target, enable the checkbox next to the build target's name in this list. For example, in Figure 7.15, the new class is assigned to the generic build target.

Figure 7.15 New Class wizard - Targets



New Member Function Wizard

The New Member Function wizard is divided into the following steps:

1. Describe the declaration of the new member function.

2. Specify file locations for the new member function.

To use the New Member Function wizard, follow these steps:

1. Describe the declaration of the new member function.

This section of the wizard, shown in Figure 7.16, lets you specify the name, return type, and parameters for the new member function. Other options are available to further describe the function.

This section includes the following parts:

Figure 7.16 New Member Function wizard - Member Function Declaration



Name

Type a name for the member function in this field.


Return Type

Enter an appropriate function return type in this field.


Namespaces required for parameters (optional)

If you wish, type a list of function parameters in this field. Example parameters are listed above the field.


Namespaces required for parameters (optional)

If desired, enter a list of namespaces required for the parameters in the Namespaces required for parameters (optional) field. Sample parameters are listed above the field.


Modifiers

Use the Access and Specifier pop-up menus to choose the access level and method specifier for the new method. Possible access levels include Public, Protected, and Private. Possible specifiers include None, Virtual, Pure Virtual, and Static. You can enable the Inline or Const checkboxes as desired to further describe the function's modifiers.

2. Specify file locations for the new member function.

This section of the wizard, shown in Figure 7.17, lets you specify file locations associated with the new member function.

Figure 7.17 New Member Function wizard - File Locations


This section includes the following parts:


Declaration

This field shows you the location of the file to which the member function's declaration will be added.


Definition

Enter in this field the path to file used for the member function's definition. Alternatively, click Existing to select the file using a standard dialog box. To create a new file to use for the member function's definition, click New and save the new file to a location on your hard disk.


Include files automatically added for return type and parameters

This field shows you a list of #include files that will be automatically added to the member function. These files are automatically added based on the return type and parameters you specified from the previous section.


Additional header include files

Enter in this field a list of other #include files for the new member function, in addition to those listed in the previous field. Some examples are provided above the field.


New Data Member Wizard

The New Data Member wizard is divided into the following steps:

1. Describe the declaration of the new data member.

2. Specify file locations for the new data member.

To use the New Data Member wizard, follow these steps:

1. Describe the declaration of the new data member.

This section of the wizard, shown in Figure 7.16, lets you specify the name, type, and initializer for the new data member. Other options are available to further describe the data member.

This section includes the following parts:

Figure 7.18 New Data Member wizard - Data Member Declaration



Name

Type a name for the data member in this field.


Type

Enter an appropriate data-member type in this field.


Namespaces required for type (optional)

If desired, enter a list of namespaces required for the type in the Type field. Sample parameters are listed above the field.


Initializer

If you wish, type an initial value for the data member in this field. Sample initializers are listed above this field.


Modifiers

Use the Access and Specifier pop-up menus to choose the access level and member specifier for the new data member. Possible access levels include Public, Protected, and Private. Possible specifiers include None, Static, and Mutable. You can enable the Const or Volatile checkboxes as desired to further describe the data member's modifiers.

2. Specify file locations for the new data member.

This section of the wizard, shown in Figure 7.19, lets you specify file locations associated with the new member function.

Figure 7.19 New Data Member wizard - File Locations


This section includes the following parts:


Declaration

This field shows you the location of the file to which the data member's declaration will be added.


Definition

This field is not available in this wizard.


Include file automatically added for member type

This field shows you the #include file that is automatically added for the data-member type.


Additional header include files

Enter in this field a list of other #include files for the new data member, in addition to the file listed in the previous field. Some examples are provided above the field.


Using the Browser

The browser provides multiple paths through the data related to your code. This section can give you a feel for how to work with the browser, and outline some techniques you can use to accomplish common tasks.

Topics in this section include:


Setting Browser Options

Browser-related menu items and browser-specific options become available when you activate the browser. See "Activating the Browser" on page 205 for information on how to enable the browser.

When the browser is enabled for your project, browser-related menu commands are enabled. These items include the Browser Contents, Class Hierarchy Window, and New Class Browser commands in the Window Menu.


TIP

A quick way to tell whether the browser is enabled is to look in the Window Menu at these browser-related menu commands. If they are enabled, the browser is active.

In addition, there are global IDE options that relate to the browser. You control how various items are colored in browser windows, and the time delay before the Browser Contextual Menu is displayed (Mac OS, Solaris, and Linux).

To tell the IDE to include items from a project's subprojects in its browser windows, see "Cache Subprojects" on page 331.

To learn how to modify these settings, see "Browser Display" on page 268 or "Context popup delay" on page 272.


Identifying Symbols in the Browser Database

There is an easy way to know whether or not a symbol is in the browser database without checking to see if a Browser Contextual Menu displays: use browser coloring. If the browser is activated, symbols that are in the browser database are displayed in editor and browser windows according to the colors you select. See "Browser Display" on page 268 for more information.


TIP

The factory default color setting is identical for all of the eight types of browser-database symbols. You can choose a different color for each symbol type if you like. However, if syntax coloring is also enabled for your code, you may find it easier to identify symbols in the browser database using only one or two colors.

Navigating Code in the Browser

There are many ways to move around in code with the browser.


Using the Contextual Menu

Perhaps most powerful and flexible way to navigate code is to use the Browser Contextual Menu. You see this menu when you right-click (Windows) or click and hold (Mac OS, Solaris, and Linux) on any symbol for which there is data in the browser database. This includes class names, routine names, global variables, class data members, and much more. To learn more, refer to "Browser Contextual Menu" on page 211.

In the Browser Window, simply selecting a class, routine, or data member displays the associated code in the window's Source pane.


Go Back and Go Forward

The browser fully supports the Go Back and Go Forward commands in the Search Menu. Regardless of the views, windows, or code you have looked at, you can always go back to what you were viewing earlier.

These commands allow you to go backward or forward through a series of changes you made. For example, suppose you use the browser to look at your project and make changes to a file. Then, you switch files and make more changes. You may do this many times. You can use the Go Back command to go back one or more actions you have performed. Even if you did not make any changes to the file, but looked at it (or a specific class or method), you can go back to that action. Similarly, once you have gone back, you can use the Go Forward command to return to where you started.

When you add the Go Back and Go Forward commands to a CodeWarrior toolbar, you can use their associated pop-up menus, as shown in Figure 7.20. Click and hold on the Go Back or Go Forward toolbar icons to display the pop-up menu.

Figure 7.20 Go Back and Go Forward toolbar buttons


Windows

Choose an action from the menu to go to that action. If you choose an action out of sequence, CodeWarrior will go to that action without going through any previous action.


Mac OS

The underlined item is your current position in the queue. Choose an action from the menu to go to that action. If you choose an action out of sequence, CodeWarrior will go to that action without going through any previous action. The CodeWarrior IDE can track up to 100 actions.


NOTE

Go Back and Go Forward do not undo any actions you performed. They allow for a more flexible method of moving around to specific places you have been in the Browser window.

Browsing Across Subprojects

The IDE normally only displays browser items for the current build target. To include browser information from the subprojects of the current build target, enable subproject caching. For more information, see "Cache Subprojects" on page 331.


Completing Symbols

The IDE has commands to complete your typing for you when you enter the name of an item for which the browser has information. Use the Find symbols with prefix, Find symbols with substring, Get next symbol, and Get previous symbol keyboard commands to find and choose browser items that match the text you have selected or just entered in a source code file. These commands are only available from the keyboard. They are not available in the IDE's menus. See "Editor Commands" on page 651 for a description of these keyboard commands.

To enter the name of a browser item that has the same characters as the text you have selected or just typed, use the Find symbols with substring keyboard command. To enter the name of a browser item that only has the same first characters, use the Find symbols with prefix keyboard command.

After using the Find symbols with substring and Find symbols with prefix commands, use the Get next symbol and Get previous symbol commands to search among the browser symbols that match the text you have selected or just entered.

After you find the browser item you want to enter, press the right arrow key to place the insertion point next to the item and continue typing.

Another way to find and enter a browser item is to select the first few characters of some text and then right-click (Windows) or click and hold (Mac OS, Solaris, and Linux) on the selection. The Browser contextual menu displays a list of matching items, as shown in Figure 7.21. Choose one of these items to automatically replace the selected text. See "Browser Contextual Menu" on page 211 for more information.

Figure 7.21 Automatically replacing selected text



Opening a Source File

There are some quick methods you can use to open a source file.

In the Browser Window, click the Open File icon when portions of the file you wish to see are displayed in the window's Source pane. See "Open File icon" on page 221 for more information.

To select a file, click on a symbol used in that file. Then use the Browser Contextual Menu to open the desired file or see a particular routine.

If you are looking at a source file, and want to see the interface file, or vice versa, simply type Ctrl/Command \Q to see the related file.


Seeing a Declaration

There are several methods used to view a declaration. The methods vary depending on the kind of symbol you investigate.

If you select a class name or data member name in a Browser Window, and the declaration is shown in the Source pane, double-click the name to open the file that contains the declaration. (If you select or double-click a routine name, you see the definition).

If you click the Class Declaration button in the Browser window, you see a class declaration in the Source pane.

When you right-click (Windows) or click and hold (Mac OS, Solaris, and Linux) on a name in any window, use the Browser Contextual Menu to open the declaration. This technique lets you see a routine declaration.


Seeing a Routine Definition

There are several methods you can use to see a routine definition:


Editing Code in the Browser

Any code visible in a Source pane is fully editable. Locate the definition with which you wish to work. When the code is displayed in the Source pane, use the same techniques you learned in the editor window to edit your code.

For more information about the CodeWarrior editor, see "Editing Source Code" on page 133.


Analyzing Inheritance

Use the Multi-Class Hierarchy Window or the Single-Class Hierarchy Window to analyze inheritance in your source code. Look for the small triangle to the left of a class name, as shown in Figure 7.7. This triangle indicates that the class has multiple ancestors. Use the associated Ancestor Class pop-up menu to jump to any ancestor class to study its descendants (or ancestors). Use the Hierarchy expansion triangle to expose or conceal subclasses.

For more information, see "Multi-Class Hierarchy Window" on page 221.


Finding Functions That Are Overrides

Use the Browser Window to find functions that are overrides. To find these overrides, disable the Show Inherited checkbox in the Browser Window toolbar. Disabling the checkbox disables the display of unchanged inherited functions. However, it does not disable functions you have overridden.

Next, look for functions that are marked as virtual with an Identifier icon. Most of these functions are likely to be overrides of inherited functions, although some could be functions you declared in the class that were not inherited from an ancestor.

To open a Symbol Window for any routine with multiple definitions, right-click (Windows) or click and hold (Mac OS, Solaris, and Linux) on a routine name, and then choose Find all implementations of. Combined with a Hierarchy view, you see precisely who overrides the routine, and where the routines are found in the class hierarchy.


Viewing MFC and PowerPlant Classes

The browser lets you view framework classes, such as the Microsoft Foundation Classes (MFC) for Windows and the PowerPlant classes for the Mac OS. If you want the browser to display these framework classes, you must include framework headers in such a way that the compiler sees them.

You should use precompiled headers to speed compilation time. However, if you simply use the precompiled headers directly, the compiler does not see the framework classes and does not generate information for the symbol database.

To resolve this problem, include a renamed copy of the source file that creates the precompiled headers in your project. These source files are named with extensions that identify precompiled headers, like .pch or .pch++. Alternatively, include as a subproject the project that creates the precompiled headers.

Including these files creates a project-specific precompiled header. CodeWarrior builds this precompiled header from within your project, exposing framework symbols to the compiler, which generates information for the browser database.

The reason you want to include a renamed copy is to avoid problems associated with multiple projects that use the same precompiled headers. When one project updates the headers, it will be marked as changed for all other projects, which then rebuild the precompiled headers. This rebuilding step defeats the purpose of the precompiled headers.


Saving a Default Browser

Browser windows have various settings that you can modify. You can preserve these modifications as your default settings.

First, set up a browser window to your liking. For example, set the size of each pane in the Browser window, and the size and location of the window itself. Then choose Save Default Window from the Window Menu. The next time you open a Browser window, it takes on the attributes you saved.

You can do the same thing for any of the browser windows. However, you must save each window's setup individually, while that window is active.

To learn about saving editor windows, see "Saving Editor Window Settings" on page 144..





Visit the Metrowerks website at: http://www.metrowerks.com
For assistance contact Metrowerks Technical Support at: support@metrowerks.com
Copyright © 1999, Metrowerks Corp. All rights reserved.

Last updated: May 24, 1999 * Chris Magnuson * John Roseborough